//
//  MainTypesListTopTableViewCell.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/11.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "MainTypesListTopTableViewCell.h"
#import "GLGWTagsView.h"

@interface MainTypesListTopTableViewCell()
@property(nonatomic,strong)MASConstraint *constraint;

@end

@implementation MainTypesListTopTableViewCell
{
    GLGWLabel *leftLabel;
    GLGWTagsView *topTageView;
    CGFloat hei;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self hiderLine:YES];
        GLGWLabel *leftLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self.contentView];
        leftLab.text = @"已选择";
        [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(12));
            make.left.equalTo(self.contentView.mas_left).offset(kHeightProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(17));
//            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        leftLabel = leftLab;
        hei = 30;
    }
    return self;
}

- (void)setArr:(NSArray *)arr
{
    _arr = arr;
    if (topTageView) {
        [topTageView removeFromSuperview];
        topTageView = nil;
    }
    topTageView = [[GLGWTagsView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(6), kHeightProportion_In_iPhoneTriploid(43), KScreenWidth, 0) tagsArray:arr config:[self tagViewConfig] tagBackImgStr:@""];
    [self.contentView addSubview:topTageView];
    if (arr.count <= 0) {
        topTageView.hidden = YES;
    } else {
        topTageView.hidden = NO;
    }
    CGFloat taH = [topTageView heighttagsArray:arr config:[self tagViewConfig]] + kHeightProportion_In_iPhoneTriploid(26);
    [leftLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(@(-taH));
    }];

    [self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(taH + kHeightProportion_In_iPhoneTriploid(12 + 17)));
    }];
}

- (FFTagsViewConfig *)tagViewConfig
{
    FFTagsViewConfig *config = [[FFTagsViewConfig alloc] init];
    config.itemHeight = kHeightProportion_In_iPhoneTriploid(20);
    config.itemHerMargin = kWidthProportion_In_iPhoneTriploid(0);
    config.itemVerMargin = kHeightProportion_In_iPhoneTriploid(6);
    config.hasBorder = NO;
    config.itemContentEdgs = 0;
    config.topBottomSpace = 0.1;
    config.fontSize = 14.0;
    config.isCanSelected = YES;
    config.isCanCancelSelected = NO;
    config.isMulti = YES;
    config.normalTitleColor = [UIColor colorWithHexString:@"#666666"];
    config.selectedTitleColor = [UIColor colorWithHexString:@"#666666"];
    return config;
}

@end
